package com.kjlink.internal.report4vue.job.controller;

import cn.xuqiudong.common.base.model.BaseResponse;
import cn.xuqiudong.common.base.model.PageInfo;
import cn.xuqiudong.quartz.model.TaskJobLog;
import cn.xuqiudong.quartz.model.TaskJobLogDetail;
import cn.xuqiudong.quartz.service.TaskJobLogDetailService;
import cn.xuqiudong.quartz.service.TaskJobLogService;
import com.kjlink.internal.report4vue.base.controller.BaseApiController;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 描述:
 *
 * @author Vic.xu
 * @since 2025-01-21 11:11
 */
@RestController
public class ApiTaskJobLogController extends BaseApiController {

    @Resource
    private TaskJobLogService taskJobLogService;

    @Resource
    private TaskJobLogDetailService taskJobLogDetailService;

    /**
     * 定时任务日志列表
     */
    @RequestMapping(value = "/taskJobLog/list", method = {RequestMethod.GET, RequestMethod.POST})
    public BaseResponse<PageInfo<TaskJobLog>> index(@RequestBody TaskJobLog lookup) {
        PageInfo<TaskJobLog> pager = taskJobLogService.page(lookup);
        return BaseResponse.success(pager);
    }

    /**
     * 定时任务日志详情
     */
    @GetMapping(value = "/taskJobLog/detail/{id}")
    public BaseResponse<List<TaskJobLogDetail>> detail(@PathVariable Integer id) {
        TaskJobLogDetail lookup = new TaskJobLogDetail();
        lookup.setTaskJobLogId(id);
        List<TaskJobLogDetail> list = taskJobLogDetailService.list(lookup);
        return BaseResponse.success(list);
    }
}
